home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl5
- #
- # resolver-config.cgi
- #
- # Copyright 1988-1996 Silicon Graphics, Inc.
- # All rights reserved.
- #
- # This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- # the contents of this file may not be disclosed to third parties, copied or
- # duplicated in any form, in whole or in part, without the prior written
- # permission of Silicon Graphics, Inc.
- #
- # RESTRICTED RIGHTS LEGEND:
- # Use, duplication or disclosure by the Government is subject to restrictions
- # as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- # and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- # successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- # rights reserved under the Copyright Laws of the United States.
- #
- # $Id: resolver-config.frm,v 1.25 1997/04/17 21:26:11 shotes Exp $
-
- BEGIN { require "/usr/WebFace/lib/CGI.pm"; import CGI; }
- require "/usr/OnRamp/lib/OnRamp.pm";
- require "/usr/OnRamp/lib/java.pm";
-
- $query = new CGI;
-
- $resolv_cf = "/etc/resolv.conf";
- $title = "Name Resolver";
-
- @order = ("nis", "bind", "local", "none");
-
- $js =
- "$js_standard
- $js_error_box
- $js_ip
- $js_hostname
- function checkForm(form) {
- if (!testNameServer(form.nmsrv1)
- || !testNameServer(form.nmsrv2)
- || !testNameServer(form.nmsrv3)) return (false);
- if (!testHostname(form.dmsrch1, form.dmsrch1.value, \"domain name\", 1)
- || !testHostname(form.dmsrch2, form.dmsrch2.value, \"domain name\", 1)
- || !testHostname(form.dmsrch3, form.dmsrch3.value, \"domain name\", 1)
- || !testHostname(form.dmsrch4, form.dmsrch4.value, \"domain name\", 1)
- || !testHostname(form.dmsrch5, form.dmsrch5.value, \"domain name\", 1)
- || !testHostname(form.dmsrch6, form.dmsrch6.value, \"domain name\", 1))
- return (false);
- return (true);
- }
- function testNameServer(Ctrl) {
- if (Ctrl.value == \"\") return (true);
- if (!testIPaddress(Ctrl.value,false)) {
- errorBox (Ctrl, \"The name server address \"
- + Ctrl.value + \"\\nis invalid.\");
- return (false);
- }
- return (true);
- }";
-
- print $query->header;
-
- if (-r $resolv_cf) { &get_resolv; }
-
- if ($query->param) {
- $help = $document_root . $ENV{"SCRIPT_NAME"};
- $help =~ s/cgi$/hlp/;
- exec $help if ($query->param('help') eq "Help");
-
- if ($query->param('doit') eq 'Ok') {
- &formValidation;
- &makeChanges; }
- }
-
- &generic;
-
- sub formValidation {
- my($count, $which);
-
- foreach $count (1..3) {
- $which = $query->param("nmsrv$count");
- &error("Invalid name server IP address #$count.")
- if $which && &check_ipaddr($which);
- }
-
- foreach $count (1..6) {
- $which = $query->param("dmsrch$count");
- &error("Invalid domain name #$which.")
- if $which && &check_hostname($which);
- }
- }
-
- sub error {
- &error_block($_[0]);
- &generic;
- exit 0;
- }
-
- sub makeChanges {
- $message = "The requested changes have been made.";
-
- open(OUT,"> $resolv_cf");
- print OUT "search ",$query->param('dmsrch1')," ",
- $query->param('dmsrch2')," ",$query->param('dmsrch3')," ",
- $query->param('dmsrch4')," ",$query->param('dmsrch5')," ",
- $query->param('dmsrch6'),"\n";
- print OUT "hostresorder";
- if ($query->param('hres1') ne 'none')
- { print OUT " ", $query->param('hres1'); }
- if ($query->param('hres2') ne 'none')
- { print OUT " ", $query->param('hres2'); }
- if ($query->param('hres3') ne 'none')
- { print OUT " ", $query->param('hres3'); }
- print OUT "\n\n";
- if ($query->param('nmsrv1')) {
- print OUT "nameserver ",$query->param('nmsrv1'),"\n"; }
- if ($query->param('nmsrv2')) {
- print OUT "nameserver ",$query->param('nmsrv2'),"\n"; }
- if ($query->param('nmsrv3')) {
- print OUT "nameserver ",$query->param('nmsrv3'),"\n"; }
- close(OUT);
- }
-
- sub get_resolv {
- $havenfs = system ("/etc/havenfs");
- if ($havenfs == 0) { @ch_order = ("bind","local","none","none"); }
- else { @ch_order = ("nis","bind","local","none"); }
- open(RESOLV, $resolv_cf);
- while (<RESOLV>) {
- if (/^\s*[#\n]/) {
- next;
- }
- chop;
- @entlist = split(/\s+/);
- if ($entlist[0] eq "hostresorder") {
- @ch_order = ("none","none","none","none");
- for ($i = 1; $i <= $#entlist; $i++) {
- if ( ($entlist[$i] ne "nis") && ($entlist[$i] ne "bind") &&
- ($entlist[$i] ne "local") ) {
- print "<p>Illegal option $entlist[$i] in $resolv_cf.";
- if ($havenfs == 0) { @ch_order = ("bind","local","none","none"); }
- else { @ch_order = ("nis","bind","local","none"); }
- last;
- }
- if ( ($entlist[$i] eq "nis") && ($havenfs != 0) ) {
- $shift_list = 1;
- next;
- }
- $ch_order[$i-1] = $entlist[$i];
- }
- shift @ch_order if ($shift_list);
- }
- elsif ($entlist[0] eq "nameserver") {
- $nmserver[$#nmserver+1] = $entlist[1];
- }
- elsif ($entlist[0] eq "domain") {
- $dmname = $entlist[1];
- }
- elsif ($entlist[0] eq "search") {
- for ($i = 1; $i <= $#entlist, $i <= 6; $i++) {
- $dmsearch[$i-1] = $entlist[$i];
- }
- }
- else {
- print "<p>Illegal option $entlist[0] in $resolv_cf.";
- last;
- }
- }
- close(RESOLV);
- }
-
- sub generic {
- &js_title_block($title,$js);
- &header_block($title);
-
- print $query->startform("POST", "", "", "NAME=StandardForm", "onSubmit=\"return runSubmit()\"");
-
- print "<i>$message</i>";
-
- print "<h3>Order of services for name and address resolution:</h3>\n";
-
- print "<font size=\"+1\"><center><table cellpadding=5 width=450>\n";
- print "<tr><th>First<th>Next<th>Last</tr>\n";
-
- print "<tr><td align=center>", $query->popup_menu(-name=>'hres1',
- -values=>\@order,
- -default=>$ch_order[0]);
- print "\n<td align=center>", $query->popup_menu(-name=>'hres2',
- -values=>\@order,
- -default=>$ch_order[1]);
- print "\n<td align=center>", $query->popup_menu(-name=>'hres3',
- -values=>\@order,
- -default=>$ch_order[2]);
- print "</tr></table></center>";
-
- print "<h3>Addresses of DNS servers to do name resolution: </h3><center>";
-
- print "<table cellpadding=5 width=450>\n";
-
- print "<tr><td align=center><strong>1</strong> ",
- $query->textfield(-name=>'nmsrv1',
- -default=>$nmserver[0],
- -size=>13,
- -maxlength=>16);
- print "\n<td align=center><strong>2</strong> ",
- $query->textfield(-name=>'nmsrv2',
- -default=>$nmserver[1],
- -size=>13,
- -maxlength=>16);
- print "\n<td align=center><strong>3</strong> ",
- $query->textfield(-name=>'nmsrv3',
- -default=>$nmserver[2],
- -size=>13,
- -maxlength=>16);
- print "\n</tr>";
- print "</table></center></font>";
-
- print "<p>\n";
- # print "The Search list for host-name lookup can be specified below.\n",
- # "The search list is normally determined from the local domain name\n",
- # "by default, it begins with the local domain name, then successive\n",
- # "parent domains that have at least two components in their names.\n",
- # "This can be changed by listing the desired domain search path\n",
- # "following the search keyword with spaces or tabs separating the names.\n",
- # "Most resolver queries are attempted using each component of the search\n",
- # "path in turn until a match is found. This process can be slow and\n",
- # "generates a lot of network traffic if the servers for the listed\n",
- # "domains are not local. Queries time out if no server is available for\n",
- # "one of the domains. The search list is limited to six domains with a\n",
- # "total of 256 characters. The first item in the list becomes the\n",
- # "default domain name, the remaining items are the other domains to\n",
- # "search after the default one.\n";
-
- print "<h3>List of domains that DNS servers will search:</h3>\n";
- print "<font size=\"+1\"><center><table cellpadding=5 width=450>\n";
- print "<tr><td align=center><strong>1</strong> ",
- $query->textfield(-name=>'dmsrch1',
- -default=>$dmsearch[0],
- -size=>13,
- -maxlength=>16);
- print "\n<td align=center><strong>2</strong> ",
- $query->textfield(-name=>'dmsrch2',
- -default=>$dmsearch[1],
- -size=>13,
- -maxlength=>16);
- print "\n<td align=center><strong>3</strong> ",
- $query->textfield(-name=>'dmsrch3',
- -default=>$dmsearch[2],
- -size=>13,
- -maxlength=>16),
- "</tr>";
- print "\n<tr><td align=center><strong>4</strong> ",
- $query->textfield(-name=>'dmsrch4',
- -default=>$dmsearch[3],
- -size=>13,
- -maxlength=>16);
- print "\n<td align=center><strong>5</strong> ",
- $query->textfield(-name=>'dmsrch5',
- -default=>$dmsearch[4],
- -size=>13,
- -maxlength=>16);
- print "\n<td align=center><strong>6</strong> ",
- $query->textfield(-name=>'dmsrch6',
- -default=>$dmsearch[5],
- -size=>13,
- -maxlength=>16);
- print "\n</tr></table></center><br>";
-
- print &js_buttons('doit','Ok','onClick="markOK()"','onClick="markOther()"');
-
- print $query->endform;
- }
-